# Maintainer: David Runge <dvzrv@archlinux.org>

pkgname=arch-release-promotion
pkgver=0.2.2
pkgrel=3
pkgdesc="Promote official releases with signatures and additional artifacts"
arch=(any)
url="https://gitlab.archlinux.org/archlinux/arch-release-promotion"
license=(GPL3)
depends=(python-dotenv python-email-validator python-gitlab python-orjson
python-prometheus_client python-pydantic python-pyxdg python-toml
python-torrentool)
makedepends=(python-build python-installer python-poetry-core python-setuptools python-wheel)
checkdepends=(python-pytest)
backup=(etc/$pkgname/projects.toml)
source=(https://files.pythonhosted.org/packages/source/${pkgname::1}/$pkgname/$pkgname-$pkgver.tar.gz)
sha256sums=('cfcc473d0805239ed76a8a90d489316af2d64717275827c1cc7b651c4ddfa718')
b2sums=('2a03da131001897ea8cbed6c0075e3f2e01d40a70e9a4760c4fa65f285b872da8e2b417a7f3f906ca6fab5f220db6a6b6fd6c901b6392763580d5ac32a560ae9')

build() {
  cd $pkgname-$pkgver
  python -m build --wheel --no-isolation
}

check() {
  cd $pkgname-$pkgver
  pytest -vv
}

package() {
  cd $pkgname-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -vDm 644 {examples/example.toml,README.rst} -t "$pkgdir/usr/share/doc/$pkgname/"
  install -vDm 644 examples/projects.toml -t "$pkgdir/etc/$pkgname/"
  install -vDm 644 examples/systemd/*.{service,timer} -t "$pkgdir/usr/lib/systemd/system/"
  install -vDm 644 examples/sysusers.d/*.conf -t "$pkgdir/usr/lib/sysusers.d/"
}
